package xx.iverson.exception;


import lombok.Getter;
import xx.iverson.enums.EnumException;

/**
 * xx.iverson.exception.BusinessException
 * 统一异常处理类
 * on 2025/6/18-下午2:47
 *
 * @author weijx
 */
@Getter
public class BusinessException extends RuntimeException {
    private final int code;
    private final String message;
    private final EnumException exception;

    public BusinessException(int code, String message, EnumException exception) {
        super(message);
        this.code = code;
        this.message = message;
        this.exception = exception;
    }

    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
        this.message = message;
        this.exception = null;
    }

    public BusinessException(EnumException exception) {
        super(exception.getErrorMsg());
        this.code = exception.getErrorCode();
        this.message = exception.getErrorMsg();
        this.exception = exception;
    }

}
